package com.third.bank.util;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

/**
 * 验证码工具类
 */
@Component
public class CodeUtils {

    private String str[] = {"0000000","00000","0000","000","00","0",""};

    /**
     * 生成验证码
     * @param tele
     * @return
     */
    public String sendCode(String tele){
        int telehash = tele.hashCode();
        long sean = 20230421;
        long code = sean ^ telehash;
        long time = System.currentTimeMillis();
        code = code ^ time;
        code = code % 1000000;
        code = code > 0 ? code : -code;

        String teleCode = code + "";
        teleCode = str[teleCode.length()] + code;

        return teleCode;
    }

    /**
     * 取出验证码
     * @param tele
     * @return
     */
    @Cacheable(value = "smsCode",key = "#tele")
    public String getCode(String tele){
        return null;
    }



}
